  //计算两点距离
  const EARTH_RADIUS = 6378137.0; // 单位 M
  const PI1 = Math.PI;
  
 
 export default{
    getRad(d) {
        return d * PI1 / 180.0;
      },
    getGreatCircleDistance(lat1, lng1, lat2, lng2) {
      let radLat1 = this.getRad(lat1);
      let radLat2 = this.getRad(lat2);
    
      let a = radLat1 - radLat2;
      let b = this.getRad(lng1) - this.getRad(lng2);
    
      let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
      s = s * EARTH_RADIUS;
      s = Math.round(s * 10000) / 10000.0; //输出为公里
    
      return s;
    }
}